function mask = ReadMask(mask_pathname, w, h, d)

mask = zeros(w, h, d);
fid = fopen(mask_pathname, 'r');
for z = 1 : d
    for y = 1 : h
        mask(:, y, z) = fread(fid, w, 'float');
    end
end
fclose(fid);

end

